//references
var menu = $("#menu");
var center = $("#center");
var listcota = $("#listcota");
var novacota = $("#novacota");
var listunderwriting = $("#listunderwriting");
var binovomarca = $("#binovomarca");
var binovoveicu = $("#binovoveicu");
var binovoender = $("#binovoender");
var binovousuar = $("#binovousuar");
var binovocorre = $("#binovocorre");
var logout = $("#logout");
// utilities funcions
function centernav(pth) {
	$.get(pth+".jsp", function(ret) {
		center.html(ret);
		$.getScriptWithTag(pth+".js");
	});
}
//TODO do it in a diynamic way
// events
listcota.click(function() {
	centernav("cotacao/listcotacao");
});
novacota.click(function() {
	centernav("cotacao/novacotacao");
});
listunderwriting.click(function() {
	centernav("proposta/listproposta");
});
logout.click(function() {
	AcessoFacade.logout({
		callback : function() {
			window.location.reload(true);
		}
	});
});
binovomarca.click(function(){
	centernav("adm/brand");
});
binovoveicu.click(function(){
	centernav("adm/vehicle");
});
binovoender.click(function(){
	centernav("adm/address");
});
binovousuar.click(function(){
	centernav("adm/user");
});
binovocorre.click(function(){
	centernav("adm/broker");
});
//screen setup
menu.menubar();
AcessoFacade.getCurrentUser({
	callback:function(ret){
		//let the user under a known scope
		window.currentuser=ret;
	}
});